Skip to content

Commit

Permalink
Merge pull request #211 from sadapon2008/jquery-ready
Browse files Browse the repository at this point in the history
resolve javascript error for Debugkit Migrations panel
  • Loading branch information
José Alejandro Alvarez Mendoza committed Oct 29, 2015
2 parents 1a29029 + be97fed commit 6832b54
Showing 1 changed file with 40 additions and 37 deletions.
77 changes: 40 additions & 37 deletions View/Elements/migrations_panel.ctp
Expand Up @@ -62,46 +62,49 @@ if (document.getElementsByClassName == undefined) {
return results;
}
}
setTimeout(function() {
DEBUGKIT.$(document).ready(function () {
DEBUGKIT.module('migrationsPanel');
DEBUGKIT.migrationsPanel = function () {
var toolbar = DEBUGKIT.toolbar,
Element = DEBUGKIT.Util.Element,
Cookie = DEBUGKIT.Util.Cookie,
Collection = DEBUGKIT.Util.Collection,
Event = DEBUGKIT.Util.Event,
migrationsHidden = false;

DEBUGKIT.module('migrationsPanel');
DEBUGKIT.migrationsPanel = function () {
var toolbar = DEBUGKIT.toolbar,
Element = DEBUGKIT.Util.Element,
Cookie = DEBUGKIT.Util.Cookie,
Collection = DEBUGKIT.Util.Collection,
Event = DEBUGKIT.Util.Event,
migrationsHidden = false;
return {
init: function () {
var button = document.getElementById('hide-migrations'),
self = this;

return {
init: function () {
var button = document.getElementById('hide-migrations'),
self = this;
Event.addEvent(button, 'click', function (event) {
event.preventDefault();
self.toggleMigrations();
});

Event.addEvent(button, 'click', function (event) {
event.preventDefault();
self.toggleMigrations();
});
var migrationsState = Cookie.read('migrationsDisplay');
console.log(migrationsState);
if (migrationsState != 'show') {
migrationsHidden = false;
this.toggleMigrations();
}
},

var migrationsState = Cookie.read('migrationsDisplay');
console.log(migrationsState);
if (migrationsState != 'show') {
migrationsHidden = false;
this.toggleMigrations();
}
},

toggleMigrations: function () {
var display = migrationsHidden ? 'show' : 'hide';
var arr = document.getElementsByClassName("migration-applied");
for (i = 0; i < arr.length; i++) {
Element[display](arr[i]);
}
Cookie.write('migrationsDisplay', display);
migrationsHidden = !migrationsHidden;
return false;
}
};
}();
DEBUGKIT.loader.register(DEBUGKIT.migrationsPanel);
toggleMigrations: function () {
var display = migrationsHidden ? 'show' : 'hide';
var arr = document.getElementsByClassName("migration-applied");
for (i = 0; i < arr.length; i++) {
Element[display](arr[i]);
}
Cookie.write('migrationsDisplay', display);
migrationsHidden = !migrationsHidden;
return false;
}
};
}();
DEBUGKIT.loader.register(DEBUGKIT.migrationsPanel);
});
}, 0);
//]]>
</script>

0 comments on commit 6832b54

Please sign in to comment.