<commit_before><?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4; */

/**
 * PHP version 5
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
 * applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied. See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * @package     omeka
 * @subpackage  neatline
 * @author      Scholars' Lab <>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @copyright   2011 The Board and Visitors of the University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 License
 */
?>
<div id="<? echo $id_prefix ?>widget" class='nlfeatures nlfeatures-edit'>
  <div class='nlfeatures-edit-nav'>
    <div class='nlfeatures-edit-nav-menu'>
      <ul>
        <li class='selected'><a href="#<? echo $id_prefix ?>maptab">NL Features</a></li>
        <li><a href="#<?echo $id_prefix ?>rawtab">Raw</a></li>
      </ul>
    </div>
    <div class='nlfeatures-edit-nav-tools'>
    </div>
  </div>
  <div class='nlfeatures-edit-body'>
    <div id="<? echo $id_prefix ?>rawtab" class='nlfeatures-edit-raw'>
      <div><em><? echo $inputNameStem ?></em></div>
      <? echo $raw_field ?>
      <? echo $use_html ?>
      &nbsp;
    </div>
    <div id="<? echo $id_prefix ?>maptab" class='nlfeatures-edit-map'>
      <div id="<? echo $id_prefix ?>map"></div>
      <div class='nlfeatures-map-tools'></div>
    </div>
  </div>
</div>
<script type='text/javascript'>
(function($) {
    var el, m, item, w, t;

<? if (! $is_html) { ?>

    // This is a sledgehammer, but the response is proportional. Basically, if
    // there are any checked checkboxes in a field, Omeka turns on TinyMCE for 
    // all textareas in the field.  In this case, it's picking up
    // an OpenLayers checkbox and setting the raw textarea up incorrectly.
    //
    // Also, because of the way TinyMCE is handled, we have to use setTimeout 
    // to make sure it gets set back *after* it's incorrectly enabled. Double 
    // ugh.
    //
    // TODO: Bring this up on #omeka and file a bug report.  
    // admin/themes/default/javascripts/items.js, around line 410, should be 
    // more specific.
    $(function() {
            // For some reason, $() isn't working for this.
            var cb = $(document.getElementById('<? echo $id_prefix ?>html'));
            if (!cb.checked) {
                var pollTinyMCE = function() {
                    var eds = $("#<? echo $id_prefix ?>rawtab .mceEditor");
                    if (eds.length == 0) {
                        setTimeout(function() { pollTinyMCE(); }, 100);
                    } else {
                        tinyMCE.execCommand('mceRemoveControl', false,
                            '<? echo $id_prefix ?>text');
                    }
                }
                setTimeout(function() { pollTinyMCE(); }, 100);
            }
        });
<? } ?>

    el = $('#<? echo $id_prefix ?>map');
    m = el.nlfeatures({
        map: {
            // Sri Lanka, just cause it's fun to say.
            // center: [8986896.64319, 866942.16213],
            center: [-8738850.21367, 4584105.47978],
            zoom: 3,
            raw_update: $('#<? echo $id_prefix ?>text')
            }
        })
        .data('nlfeatures');
    item = {
        id: el.attr('id'),
        title: 'Coverage',
        name: 'Coverage',
        wkt: <? echo json_encode(is_null($value) ? '' : $value) ?>
    };
    m.loadLocalData([item]);
    m.editJson(item, true);
    // TODO: Delete this line.
    window._nlfeatureMap = m;

    w = $("#<? echo $id_prefix ?>widget");
    t = w.simpletab({
        nav_list: ".nlfeatures-edit-nav-menu ul",
        tabchange: function(event, data) {
                data.tab.anchors.each(function() {
                        $(this.parentNode).removeClass('selected');
                    });
                data.a.parent().addClass('selected');
                event.preventDefault();
            }
    });
})(jQuery);
</script>
<commit_msg>Refactored code to initialize the OpenLayers map into a function.<commit_after><?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4; */

/**
 * PHP version 5
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
 * applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied. See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * @package     omeka
 * @subpackage  neatline
 * @author      Scholars' Lab <>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @copyright   2011 The Board and Visitors of the University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 License
 */
?>
<div id="<? echo $id_prefix ?>widget" class='nlfeatures nlfeatures-edit'>
  <div class='nlfeatures-edit-nav'>
    <div class='nlfeatures-edit-nav-menu'>
      <ul>
        <li class='selected'><a href="#<? echo $id_prefix ?>maptab">NL Features</a></li>
        <li><a href="#<?echo $id_prefix ?>rawtab">Raw</a></li>
      </ul>
    </div>
    <div class='nlfeatures-edit-nav-tools'>
    </div>
  </div>
  <div class='nlfeatures-edit-body'>
    <div id="<? echo $id_prefix ?>rawtab" class='nlfeatures-edit-raw'>
      <div><em><? echo $inputNameStem ?></em></div>
      <? echo $raw_field ?>
      <? echo $use_html ?>
      &nbsp;
    </div>
    <div id="<? echo $id_prefix ?>maptab" class='nlfeatures-edit-map'>
      <div id="<? echo $id_prefix ?>map"></div>
      <div class='nlfeatures-map-tools'></div>
    </div>
  </div>
</div>
<script type='text/javascript'>
(function($) {
    var w, t;

    function initOpenLayerMap() {
        var el, m, item;
        el = $(document.getElementById('<? echo $id_prefix ?>map'));
        m = el.nlfeatures({
            map: {
                // Sri Lanka, just cause it's fun to say.
                // center: [8986896.64319, 866942.16213],
                center: [-8738850.21367, 4584105.47978],
                    zoom: 3,
                    raw_update: $('#<? echo $id_prefix ?>text')
            }
        })
            .data('nlfeatures');
        item = {
            id: el.attr('id'),
                title: 'Coverage',
                name: 'Coverage',
                wkt: <? echo json_encode(is_null($value) ? '' : $value) ?>
        };
        m.loadLocalData([item]);
        m.editJson(item, true);
        // TODO: Delete this line.
        window._nlfeatureMap = m;
    }

    // This is a sledgehammer, but the response is proportional. Basically, if
    // there are any checked checkboxes in a field, Omeka turns on TinyMCE for 
    // all textareas in the field.  In this case, it's picking up
    // an OpenLayers checkbox and setting the raw textarea up incorrectly.
    //
    // Also, because of the way TinyMCE is handled, we have to use setTimeout 
    // to make sure it gets set back *after* it's incorrectly enabled. Double 
    // ugh.
    //
    // TODO: Bring this up on #omeka and file a bug report.  
    // admin/themes/default/javascripts/items.js, around line 410, should be 
    // more specific.
    $(function() {
        initOpenLayerMap();
<? if (!$is_html) { ?>
        // For some reason, $() isn't working for this.
        var cb = $(document.getElementById('<? echo $id_prefix ?>html'));
        if (!cb.checked) {
            var pollTinyMCE = function() {
                var rawtab = document.getElementById('<? echo $id_prefix ?>rawtab');
                var eds = document.getElementsByClassName('mceEditor');
                if (eds.length == 0) {
                    setTimeout(function() { pollTinyMCE(); }, 100);
                } else {
                    tinyMCE.execCommand('mceRemoveControl', false,
                        '<? echo $id_prefix ?>text');
                }
            }
            setTimeout(function() { pollTinyMCE(); }, 100);
        }
<? } ?>
    });

    w = $("#<? echo $id_prefix ?>widget");
    t = w.simpletab({
        nav_list: ".nlfeatures-edit-nav-menu ul",
        tabchange: function(event, data) {
                data.tab.anchors.each(function() {
                        $(this.parentNode).removeClass('selected');
                    });
                data.a.parent().addClass('selected');
                event.preventDefault();
            }
    });
})(jQuery);
</script>

{'fraction_non_alphanumeric': 0.1491640257895312, 'fraction_numerical': 0.01595454048737843, 'mean_word_length': 2.142857142857143, 'pattern_counts': {'":': 0, '<': 135, '<?xml version=': 0, '>': 135, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5183800', 'n_tokens_mistral': 2835, 'n_tokens_neox': 2679, 'n_words': 803}