<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[GlotPress] [478] trunk:
  Switch to live events to prevent binding save button events more than once and thus firing the event more than once</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>478</dd>
<dt>Author</dt> <dd>nbachiyski</dd>
<dt>Date</dt> <dd>2010-04-23 22:23:24 +0000 (Fri, 23 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Switch to live events to prevent binding save button events more than once and thus firing the event more than once</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkgpincludesassetsloaderphp">trunk/gp-includes/assets-loader.php</a></li>
<li><a href="#trunkjseditorjs">trunk/js/editor.js</a></li>
<li><a href="#trunkjstranslationspagejs">trunk/js/translations-page.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkgpincludesassetsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/gp-includes/assets-loader.php (477 => 478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/gp-includes/assets-loader.php        2010-04-23 22:05:25 UTC (rev 477)
+++ trunk/gp-includes/assets-loader.php        2010-04-23 22:23:24 UTC (rev 478)
</span><span class="lines">@@ -24,10 +24,10 @@
</span><span class="cx">         $scripts-&gt;add( 'jquery-ui-autocomplete', null, array('jquery-ui'), '1.8' );
</span><span class="cx">         $scripts-&gt;add( 'jquery-ui-selectable', null, array('jquery-ui'), '1.8' );
</span><span class="cx">         $scripts-&gt;add( 'jquery-ui-tabs', null, array('jquery-ui'), '1.8' );
</span><del>-        $scripts-&gt;add( 'common', '/common.js', array( 'jquery' ) );
-        $scripts-&gt;add( 'editor', '/editor.js', array( 'common', 'google-js-api' ) );
-        $scripts-&gt;add( 'translations-page', '/translations-page.js', array( 'common' ) );
-        $scripts-&gt;add( 'mass-create-sets-page', '/mass-create-sets-page.js', array( 'common' ) );
</del><ins>+        $scripts-&gt;add( 'common', '/common.js', array( 'jquery' ), '20100423' );
+        $scripts-&gt;add( 'editor', '/editor.js', array( 'common', 'google-js-api' ), '20100423' );
+        $scripts-&gt;add( 'translations-page', '/translations-page.js', array( 'common' ), '20100423' );
+        $scripts-&gt;add( 'mass-create-sets-page', '/mass-create-sets-page.js', array( 'common' ), '20100423' );
</ins><span class="cx">         $scripts-&gt;add( 'google-js-api', 'http://www.google.com/jsapi', array(), '' );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkjseditorjs"></a>
<div class="modfile"><h4>Modified: trunk/js/editor.js (477 => 478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/js/editor.js        2010-04-23 22:05:25 UTC (rev 477)
+++ trunk/js/editor.js        2010-04-23 22:23:24 UTC (rev 478)
</span><span class="lines">@@ -21,10 +21,6 @@
</span><span class="cx">                 editor.original_id = $gp.editor.original_id_from_row_id(row_id);
</span><span class="cx">                 editor.translation_id = $gp.editor.translation_id_from_row_id(row_id);
</span><span class="cx">                 $gp.editor.current = editor;
</span><del>-                $('a.close', editor).click($gp.editor.hooks.hide);
-                $('button.ok', editor).click($gp.editor.hooks.ok);
-                $('a.copy').click($gp.editor.hooks.copy);
-                $('a.gtranslate').click($gp.editor.hooks.google_translate);
</del><span class="cx">                 editor.show();
</span><span class="cx">                 editor.preview.hide();
</span><span class="cx">                 $('tr:first', $gp.editor.table).hide();
</span><span class="lines">@@ -48,10 +44,14 @@
</span><span class="cx">                 $gp.editor.current = null;
</span><span class="cx">         },
</span><span class="cx">         install_hooks: function() {
</span><del>-                $('a.edit', $gp.editor.table).click($gp.editor.hooks.show);
-                $('tr.preview', $gp.editor.table).dblclick($gp.editor.hooks.show);
-                $('a.discard-warning', $gp.editor.table).click($gp.editor.hooks.discard_warning);
-                $('select.priority', $gp.editor.table).change($gp.editor.hooks.set_priority);
</del><ins>+                $('a.edit', $gp.editor.table).live('click', $gp.editor.hooks.show);
+                $('a.close', 'tr.editor').live('click', $gp.editor.hooks.hide);
+                $('a.copy', 'tr.editor').live('click', $gp.editor.hooks.copy);
+                $('a.gtranslate', 'tr.editor').live('click', $gp.editor.hooks.google_translate);
+                $('a.discard-warning', 'tr.editor').live('click', $gp.editor.hooks.discard_warning);
+                $('button.ok', 'tr.editor').live('click', $gp.editor.hooks.ok);
+                $('tr.preview', $gp.editor.table).live('dblclick', $gp.editor.hooks.show);
+                $('select.priority', $gp.editor.table).live('change', $gp.editor.hooks.set_priority);
</ins><span class="cx">         },
</span><span class="cx">         replace_current: function(html) {
</span><span class="cx">                 if (!$gp.editor.current) return;
</span><span class="lines">@@ -60,11 +60,10 @@
</span><span class="cx">                 $gp.editor.next();
</span><span class="cx">                 old_current.preview.remove();
</span><span class="cx">                 old_current.remove();
</span><del>-                $gp.editor.install_hooks();
</del><span class="cx">                 $gp.editor.current.preview.fadeIn(800);
</span><span class="cx">         },
</span><span class="cx">         save: function(button) {
</span><del>-                if (!$gp.editor.current) return;
</del><ins>+                if (!$gp.editor.current) return;                
</ins><span class="cx">                 var editor = $gp.editor.current;
</span><span class="cx">                 button.attr('disabled', 'disabled');
</span><span class="cx">                 $gp.notices.notice('Saving&amp;hellip;');
</span><span class="lines">@@ -102,7 +101,6 @@
</span><span class="cx">                         success: function(data){
</span><span class="cx">                                 select.attr('disabled', '');
</span><span class="cx">                                 $gp.notices.success('Priority set!');
</span><del>-                                // set CSS class
</del><span class="cx">                                 var new_priority_class = 'priority-'+$('option:selected', select).text();
</span><span class="cx">                                 $gp.editor.current.addClass(new_priority_class);
</span><span class="cx">                                 $gp.editor.current.preview.addClass(new_priority_class);
</span></span></pre></div>
<a id="trunkjstranslationspagejs"></a>
<div class="modfile"><h4>Modified: trunk/js/translations-page.js (477 => 478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/js/translations-page.js        2010-04-23 22:05:25 UTC (rev 477)
+++ trunk/js/translations-page.js        2010-04-23 22:23:24 UTC (rev 478)
</span><span class="lines">@@ -8,7 +8,7 @@
</span><span class="cx">         
</span><span class="cx"> 
</span><span class="cx">         // make the whole table cell, containing the checkbox clickable
</span><del>-        $('table#translations td.checkbox').live( 'click', function (e) {
</del><ins>+        $('table#translations td.checkbox').live('click', function (e) {
</ins><span class="cx">                 if ($(e.target).is('input')) return true;
</span><span class="cx">                 var cb = this.getElementsByTagName('input')[0];
</span><span class="cx">                 cb.checked = !cb.checked;
</span></span></pre>
</div>
</div>

</body>
</html>